import { fetchUpOrDispatchAPI } from '@/api/dispatch/pickUpAPI'

const actions = {
  /*
  * 获取派件作业的action
  *  */
  async fetchDeliveryAction(context, pageParams) {
    const { data } = await fetchUpOrDispatchAPI(pageParams)
    context.commit('setDeliveryMutation', data)
  }
}

const mutations = {
  /*
  * 获取派件作业的mutation
  *  */
  setDeliveryMutation(state, { items, counts }) {
    state.deliveryList = items
    state.counts = Number(counts)
  }
}
const state = () => {
  return {
    counts: 0,
    deliveryList: []
  }
}

export default {
  actions,
  mutations,
  state,
  namespaced: true
}
